package com.zhangjun.entity;

import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @author 张钧
 * @Description
 * @create 2022-09-20 12:53
 */
@ToString
@Accessors(chain = true)
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {
	private static final long serialVersionUID = 1L;
	@Getter
	@Setter
	private Integer code;
	@Getter
	@Setter
	private String msg;
	@Getter
	@Setter
	private T data;
	public static <T> Result<T> ok(){
		return restResult(200,"成功",null);
	}

	public static <T> Result<T> ok(String msg){
		return restResult(200,msg,null);
	}

	public static <T> Result<T> ok(String msg,T data){
		return restResult(200,msg,data);
	}

	public static <T> Result<T> ok(T data){
		return restResult(200,"成功",data);
	}

	public static <T> Result<T> restResult(Integer code,String msg,T data){
		return new Result<T>().setCode(code).setMsg(msg).setData(data);
	}
}
